<template>

  <div class="width">
    <Header></Header>
    <Swiper :banner="msg.focusList" />
    <!-- 三剑客 -->
    <div class="content">
      <div class="servicePolicy flex">
        <div class="icon" v-for="(i, index) in msg.policyDescList" :key="index">
          <i><img :src="i.icon" /></i><span class="text">{{ i.desc }}</span>
        </div>
      </div>
    </div>
    <!-- 图标导航 -->
    <div class="indexNav flex">
      <div
        class="item flex"
        v-for="item in msg.kingKongList"
        :key="item.schemeUrl"
      >
        <div class="icon">
          <img :src="item.picUrl" />
        </div>
        <div class="txt">{{ item.text }}</div>
      </div>
    </div>
    <div class="content">
      <!-- 新人专享礼 -->
      <div class="indexFloor1">
        <div class="moduleTitle"><span class="txt">新人专享礼</span></div>
        <div class="moduleContent flex">
          <div class="left">
            <div class="name">新人专享礼包</div>
            <div class="imgWrap">
              <img
                src="//yanxuan.nosdn.127.net/static-union/1648017994dd2933.png"
              />
            </div>
          </div>
          <div class="right flex">
            <div
              class="module module1"
              v-for="item in msg.indexActivityModule"
              :key="item.targetUrl"
            >
              <div class="cnt">
                <div class="title">{{ item.title }}</div>
                <div class="subTitle">{{ item.subTitle }}</div>
                <div class="tag">{{ item.tag }}</div>
              </div>
              <div class="picWrap">
                <img :src="item.showPicUrl" />
                <div class="discount">
                  <div class="line1">{{ item.activityPrice }}</div>
                  <div class="line2">{{ item.originPrice }}</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 类目热销榜 -->
      <div class="indexFloor2">
        <div class="moduleTitle">类目热销榜</div>
        <div class="moduleContent">
          <div class="line1 flex">
            <div
              class="item-big item-1"
              v-for="item in msg.categoryList.slice(0, 1)"
              :key="item.targetUrl"
            >
              <div class="name">
                <span class="txt">{{ item.categoryName }}</span>
              </div>
              <div class="imgWrap">
                <img :src="item.showPicUrl" />
              </div>
            </div>
            <div
              class="item-big item-2"
              v-for="item in msg.categoryList.slice(1, 2)"
              :key="item.targetUrl"
            >
              <div class="name">
                <span class="txt">{{ item.categoryName }}</span>
              </div>
              <div class="imgWrap">
                <img :src="item.showPicUrl" />
              </div>
            </div>
          </div>
          <div class="line2 flex">
            <div
              class="item"
              v-for="item in msg.categoryList.slice(1)"
              :key="item.targetUrl"
            >
              <div class="name">{{ item.categoryName }}</div>
              <div class="imgWrap">
                <img :src="item.showPicUrl" />
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 无标题 -->
      <div class="indexFloor3 flex">
        <div class="left flex">
          <div class="title">趣出游</div>
          <div class="desc">防晒上新</div>
          <img
            src="https://yanxuan.nosdn.127.net/static-union/167930069054efc9.png?quality=75&amp;type=webp&amp;imageView&amp;thumbnail=150x150"
          />
        </div>
        <div class="right">
          <div class="title">严选众筹</div>
          <div class="desc">探索美与用</div>
          <div class="picList">
            <img
              class="pic1"
              src="https://yanxuan-item.nosdn.127.net/d398ebb1be7fd30f1e3c2a41b30c4ba9.png?quality=75&amp;type=webp&amp;imageView&amp;thumbnail=150x150"
            />
            <img
              class="pic2"
              src="https://yanxuan-item.nosdn.127.net/e9f01fb9a3d9e18f7a42dd9231390beb.png?quality=75&amp;type=webp&amp;imageView&amp;thumbnail=150x150"
            />
          </div>
        </div>
      </div>
      <!-- 为你推荐 -->
      <goods></goods>
    <!-- footer -->
    <div class="indexFoot">
      <div class="bd">
        <a class="m25">下载APP</a>
        <a>电脑版</a>
      </div>
      <p class="copyright">
        网易公司版权所有 © 1997-2023<br />食品经营许可证：JY13301080111719
      </p>
    </div>
  </div>
  </div>
</template>

<script setup lang="ts">
import Header from "./Header/index.vue";
import Swiper from "./Swiper/Index.vue";
import { onMounted, ref } from "vue";
import goods from './goods/index.vue'
// 引入仓库数据
import { indexMsg } from "../../stores/indexMsg/indexMsg";
// 使用仓库数据
const msg = indexMsg();

// 加载调用仓库方法请求数据
onMounted(() => {
  msg.getIndex();
});
</script>

<style scoped lang="less">
* {
  padding: 0;
  margin: 0;
}
.width{
  width: 375px;
}
.flex {
  display: flex;
}

.content {
  padding: 0 15px;
  width: 100%;
  box-sizing: border-box;
  /*轮播下三剑客**/
  .servicePolicy {
    width: 100%;
    height: 36px;
    align-items: center;

    .icon {
      flex: 1;
      display: flex;
      align-items: center;
      font-size: 12px;
      .text {
        margin-left: 4px;
      }
      i {
        display: inline-block;
        width: 16px;
        height: 16px;
        background-size: cover;
        img {
          width: 100%;
          height: auto;
        }
      }
      .icon1 {
        background-image: url("./images/servicePolicy1.png");
      }
      .icon2 {
        background-image: url("./images/servicePolicy2.png");
      }
      .icon3 {
        background-image: url("./images/servicePolicy3.png");
      }
    }
  }
  /*新人专享礼**/
  .indexFloor1 {
    width: 100%;
    margin: 40px 0;
    overflow: hidden;
    .moduleTitle {
      font-size: 16px;
      width: 100%;
      height: 45px;
      text-align: center;
      .txt {
        color: #333;
        position: relative;
        &::before {
          content: "";
          position: absolute;
          left: -25px;
          top: 9px;
          width: 15px;
          height: 2px;
          background: #333;
        }
        &::after {
          content: "";
          position: absolute;
          right: -25px;
          top: 9px;
          width: 15px;
          height: 2px;
          background: #333;
        }
      }
    }
    .moduleContent {
      width: 100%;
      height: 220px;
      justify-content: space-between;
      .left {
        width: 171px;
        height: 217px;
        background: #f9e9cf;
        padding: 15px;
        border-radius: 4px;
        box-sizing: border-box;
        .name {
          font-size: 16px;
        }
        .imgWrap {
          text-align: center;
          img {
            width: 129px;
            height: 129px;
            margin: 18px auto;
          }
        }
      }
      .right {
        width: 171px;
        height: 217px;
        flex-wrap: wrap;
        align-content: space-between;
        &:first-child {
          background: #fbe2d3;
        }
        .module1 {
          background: #fbe2d3;
        }
        .module {
          width: 100%;
          height: 107px;
          border-radius: 4px;
          background: #ffecc2;
          position: relative;
          .cnt {
            padding: 10px 15px;
            .title {
              font-size: 15px;
            }
            .subTitle {
              font-size: 13px;
              color: #7f7f7f;
            }
            .tag {
              font-size: 12px;
              color: #fff;
              text-align: center;
              width: 55px;
              padding: 0 5px;
              border-radius: 3px;
              background: #cbb693;
              opacity: 0.6;
            }
          }
          .picWrap {
            position: absolute;
            right: 0;
            bottom: 0;
            width: 100px;
            height: 100px;
            img {
              width: 100%;
              height: auto;
            }
            .discount {
              position: absolute;
              top: 0;
              right: 15px;
              width: 40px;
              height: 40px;
              border-radius: 50%;
              opacity: 0.7;
              text-align: center;
              background: #f59524;
              .line1 {
                padding-top: 6px;
                color: white;
                font-size: 12px;
              }
              .line2 {
                color: white;
                font-size: 12px;
                text-decoration: line-through;
              }
            }
          }
        }
      }
    }
  }
  /*类目热销榜**/
  .indexFloor2 {
    width: 100%;
    .moduleTitle {
      font-size: 16px;
      width: 100%;
      height: 45px;
    }
    .moduleContent {
      .line1 {
        margin-bottom: 5px;
        justify-content: space-between;
        .item-big {
          width: 170px;
          height: 100px;
          border-radius: 3px;
          position: relative;
          .name {
            margin-top: 30px;
            margin-left: 12px;
            position: relative;
            .txt {
              font-size: 14px;
              color: #333;
              &::before {
                content: "";
                position: absolute;
                left: 0;
                bottom: -5px;
                width: 30px;
                height: 2px;
                background: #333;
              }
            }
          }
          .imgWrap {
            position: absolute;
            top: 0;
            right: 0;
            width: 100px;
            height: 100px;
            img {
              width: 100%;
              height: auto;
            }
          }
        }
        .item-1 {
          background: #f9f3e4;
        }
        .item-2 {
          background: #ebeff6;
        }
      }
      .line2 {
        flex-wrap: wrap;
        justify-content: space-between;
        .item {
          width: 82px;
          height: 90px;
          border-radius: 3px;
          background: #f5f5f5;
          margin-bottom: 5px;
          .name {
            font-size: 12px;
            margin-top: 5px;
            text-align: center;
          }
          .imgWrap {
            width: 60px;
            height: 60px;
            margin: 0 auto;
            img {
              width: 100%;
              height: auto;
            }
          }
        }
      }
    }
  }

  /*无标题**/
  .indexFloor3 {
    width: 100%;
    margin-top: 20px;
    margin-bottom: 40px;
    justify-content: space-between;
    .left {
      width: 120px;
      height: 135px;
      background-color: #f5f5f5;
      padding: 12px 0;
      box-sizing: border-box;
      flex-direction: column;
      align-items: center;
      justify-content: space-between;
      .title {
        font-size: 14px;
      }
      .desc {
        font-size: 12px;
        color: rgb(127, 127, 127);
      }
      img {
        width: 72px;
        height: 72px;
      }
    }
    .right {
      width: 220px;
      height: 135px;
      background-color: #f5f5f5;
      padding: 12px 0 12px 25px;
      box-sizing: border-box;
      .title {
        font-size: 14px;
      }
      .desc {
        font-size: 12px;
        color: rgb(255, 111, 15);
      }
      .picList {
        img {
          width: 72px;
          height: 72px;
        }
        .pic2 {
          margin-left: 30px;
        }
      }
    }
  }
    /*为你推荐**/
    .indexFloor4{
      width: 100%;
       .enderTitle{
        font-size: 18px;
        width: 359px;
        height: 45px;
       }
       .list{
        height: 290px;
        width: 170px;
        background-color: #f59524;
       }
}
}
/*footer**/
.indexFoot {
  width: 100%;
  height: 120px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  background-color: #414141;
  margin-bottom: 50px;
  padding: 27px 10px;
  box-sizing: border-box;
  .bd {
    text-align: center;
    margin-bottom: 18px;
    a {
      width: 85px;
      height: 30px;
      color: #fff;
      font-size: 13px;
      text-align: center;
      line-height: 30px;
      border: 1px solid #fff;
      border-radius: 3px;
      display: inline-block;
    }
    .m25 {
      margin-right: 25px;
    }
  }
  .copyright {
    text-align: center;
    font-size: 12px;
    line-height: 16px;
    color: #999;
  }
}
/*导航图标**/
.indexNav {
  width: 100%;
  flex-wrap: wrap;
  .item {
    width: 20%;
    margin-top: 5px;
    flex-wrap: wrap;
    justify-content: center;
    .icon {
      img {
        width: 55px;
        height: 55px;
      }
    }
    .txt {
      font-size: 12px;
      margin-top: 5px;
      white-space: nowrap;
    }
  }
}
</style>